home *** CD-ROM | disk | FTP | other *** search
/ L' Effet Pommier 3 / L'Effet Pommier - Volume 03.iso / Programmation / Alpha ƒ / Tcl / SystemCode / menus.tcl < prev    next >
Text File  |  1996-01-23  |  9KB  |  474 lines

  1. # My menus.        
  2.  
  3. menu -n File -p fileMenuProc {
  4.     "/Nnew"
  5.     "/Oopen╔"
  6.     {menu -n recent {}}
  7.     "<S/Wclose"
  8.     "<S<I<O/WcloseAll"
  9.     "(-"
  10.     "<S/Ssave"
  11.     "<S<I<O/SsaveAll"
  12.     "<SsaveACopyAs╔"
  13.     "<SsaveAs╔"
  14.     "<E<SrevertToBackup"
  15.     "<Srevert"
  16.     "(-"
  17.     "<S/Y<Oshell"
  18.     "<S/Y<B<OtoolserverShell"
  19.     "(-"
  20.     "pageSetup╔"
  21.     {menu -n print {}}
  22.     "(-"
  23.     "/Qquit"
  24. }
  25.  
  26.  
  27. proc fileMenuProc {menu item} {
  28.     if {$item == "open"} {
  29.         findFile
  30.     } elseif {$item == "close"} {
  31.         killWindow
  32.     } else {
  33.         $item
  34.     }
  35. }
  36.  
  37.  
  38. menu -n Edit {
  39.     "/Zundo"
  40.     "/Z<I<Oredo"
  41.     "/Lload"
  42.     "(-"
  43.     "/X<Scut"
  44.     "/X<S<I<Ocut&Append"
  45.     "/C<Scopy"
  46.     "/C<S<I<Ocopy&Append"
  47.     "/V<Spaste"
  48.     "/V<S<I<OpastePop"
  49.     "/A<SselectAll"
  50.     "/A<S<I<OselectParagraph"
  51.     "clear"
  52.     "(-"
  53.     {menu -n emacs {}}
  54.     "/`<Stwiddle"
  55.     "/`<S<I<OtwiddleWords"
  56.     "(-"
  57.     {/[<SshiftLeft}
  58.     {/[<S<I<OshiftLeftSpace}
  59.     {/]<SshiftRight}
  60.     {/]<S<I<OshiftRightSpace}
  61.     "/Bbalance"
  62. }
  63.  
  64.  
  65. menu -n Search {
  66.     "/F<Sfind╔"
  67.     "/F<S<I<OsearchStart"
  68.     "/G<SfindAgain"
  69.     "/G<S<I<OfindAgainBackward"
  70.     "/MfindInNextFile"
  71.     "/E<SenterSearchString"
  72.     "/E<S<I<OenterReplaceString"
  73.     "(-"
  74.     "/S<BquickFind"
  75.     "/R<BreverseQuickFind"
  76.     "(-"
  77.     "/Rreplace"
  78.     "/Hreplace&FindAgain"
  79.     "<S/R<O<IreplaceAll"
  80.     "<S/R<O<I<BreplaceInFileset"
  81.     "(-"
  82.     "/,<BpushPosition"
  83.     "/.<BpopPosition"
  84.     "/G<IgotoLine"
  85. }
  86. proc pushPosition {} {pushMark}
  87. proc popPosition {} {popMark}
  88. #     {menu -n NamedClipboards -p namedClipMenuProc {"copy╔" "cut╔" "paste╔"}}
  89. #     {menu -n registers { pointToRegister jumpToRegister }}
  90.  
  91. proc namedMarkProc {menu item} {
  92.     switch $item {
  93.         "markFile"            {markFile; message "File marked."}
  94.         "set"                 {setNamedMark}
  95.         "goto"                {gotoFileMark}
  96.         "remove"            {removeNamedMark}
  97.         "sort"                {sortMarksFile}
  98.         "sortByPosition"    {orderMarks}
  99.     }
  100. }
  101.  
  102. proc unnamedMarkproc {menu item} {
  103.     switch $item {
  104.         "set"                     {setMark}
  105.         "exchangePointAndMark"    {exchangePointAndMark}
  106.         "hilite"                {markHilite}
  107.     }
  108. }
  109.     
  110. proc installProc {menu item} {
  111.     switch $item {
  112.         "Electric Alias"     {loadElectricAlias}
  113.         "LaTeX 2.09"        {loadLaTeX}
  114.         "LaTeX2e"            {loadLaTeX}
  115.         "MacPerl"            {loadMacPerl}
  116.     }
  117. }
  118.  
  119.  
  120. menu -n "Utils" {
  121.         {menu -n fileUtils {
  122.             "insertPathName╔"
  123.             "insertFile╔"
  124.             "fileRemove╔"
  125.             "fileInfo╔"
  126.             "wordCount"
  127.             "textToAlpha"}}
  128.         {menu -m -n compare -p compareProc {
  129.             "Windows"
  130.             "Files╔"
  131.             "Directories╔"}}
  132.         {menu -n asciiEtc {
  133.             "quoteChar"
  134.             "(-"
  135.             "keyCode"
  136.             "keyAscii"
  137.             "getAscii"
  138.             "insertAscii"}}
  139.         {menu -n KbdMacros {
  140.             "/qstartKeyboardMacro"
  141.             "/rendKeyboardMacro"
  142.             "/sexecuteKeyboardMacro"
  143.             "dumpMacro"}}
  144.         "(-"
  145.         "sendUrl"
  146.         {menu -m -n switchTo -p switchProc {}}
  147.         {menu -n internetConfig -p internetProc {
  148.             goTo
  149.             help
  150.             (-
  151.             webBrowser
  152.             newsClient
  153.             mailClient
  154.             (-
  155.             ftpClient
  156.             gopherClient
  157.             telnetClient
  158.             (-
  159.             resolveUrl
  160.             viewHtmlFile
  161.         }}
  162.         "(-"
  163.         "/M<I<OmatchingLines"
  164.         "gotoMatch"
  165.         "/inextMatch"
  166.         "(-"
  167.         "/jcmdDoubleClick"
  168. }
  169.  
  170.  
  171. proc compareProc {menu item} {
  172.     catch {compare$item} msg
  173.     message $msg
  174. }
  175.  
  176. proc namedClipMenuProc {menu item} {
  177.     switch $item {
  178.         "copy"         "copyNamedClipboard"
  179.         "cut"         "cutNamedClipboard"
  180.         "paste"     "pasteNamedClipboard"
  181.     }
  182. }
  183.  
  184.         
  185. menu    -n Config {
  186.     {menu -n "Current Mode" -p modeMenuProc {
  187.         "menus╔"
  188.         "flags╔"
  189.         "editPrefs"
  190.         "loadPrefs╔"
  191.         "describeMode"
  192.     }}
  193.     {menu -n Global -p globalOptions {
  194.         "flags╔"
  195.         "editPrefs"
  196.         "/kdescribeBinding"
  197.         "listBindings"
  198.         "listFunctions"}}
  199.     "viewSavedSetting╔"
  200.     "removeSavedSetting╔"
  201.     "(-"
  202.     {menu -n appPaths {}}
  203.     {menu -m -n install -p installProc {
  204.         "Electric Alias"
  205.         "(-"
  206.         "LaTeX2e"
  207.         "LaTeX 2.09"
  208.     }}
  209.     "(-"
  210.     "/lsetFontsTabs╔"
  211.     {menu -n redefineColors -p colorProc {
  212.         foreground
  213.         background
  214.         "(-"
  215.         blue
  216.         cyan
  217.         green
  218.         magenta
  219.         red
  220.         white
  221.         yellow
  222.         "(-"
  223.         color_9
  224.         color_10
  225.         color_11
  226.         color_12
  227.         color_13
  228.         color_14
  229.         color_15}}
  230. }
  231.  
  232.  
  233. proc colorProc {menu item} {
  234.     global colorInds modifiedArrVars
  235.     if {[info exists colorInds($item)]} {
  236.         set color [eval [list colorTriple "New \"$item\":"] $colorInds($item)]
  237.     } else {
  238.         switch $item {
  239.             foreground    { set inds "0 0 0" }
  240.             background    { set inds "65535 65535 65535" }
  241.             blue        { set inds "0 0 65535" }
  242.             cyan        { set inds "61404 11464 34250" }
  243.             green        { set inds "1151 33551 8297" }
  244.             magenta        { set inds "44790 1591 51333" }
  245.             red            { set inds "65535 0 0" }
  246.             white        { set inds "65535 65535 65535" }
  247.             yellow        { set inds "61834 64156 12512" }
  248.             default        { set inds "65535 65535 65535" }
  249.         }
  250.         set color [eval [list colorTriple "New \"$item\":"] $inds]
  251.     }
  252.     eval setRGB $item $color
  253.  
  254.     set colorInds($item) $color
  255.     lappend modifiedArrVars colorInds
  256. }
  257.  
  258.  
  259.         
  260. # ==== NOTE:  rectMarkHilite, onespace, centerRedraw, doTab
  261. menu    -n Text {
  262.         "/I<SfillParagraph"
  263.         "/I<S<O<IwrapParagraph"
  264.         "/I<S<O<UsentenceParagraph"
  265.         "/U<S<OfillRegion"
  266.         "/U<S<I<OwrapRegion"
  267.         "<E<SparagraphToLine"
  268.         "<SlineToParagraph"
  269.         "(-"
  270.         "<SreverseSort"
  271.         "<SsortLines"
  272.         "/L<I<OspellcheckWindow"
  273.         "(-"
  274.         "zapInvisibles"
  275.         "<SspacesToTabs"
  276.         "<StabsToSpaces"
  277.         "<S<EindentRegion"
  278.         "<SindentLine"
  279.         "<E<SdowncaseRegion"
  280.         "<SupcaseRegion"
  281.         "(-"
  282.         {menu -n Strings {
  283.             "<SremovePrefix"
  284.             "<SinsertPrefix"
  285.             "<S<EremoveSuffix"
  286.             "<SinsertSuffix"
  287.             "setPrefix"
  288.             "setSuffix"
  289.             }}
  290.         "/D<ScommentLine"
  291.         "/D<S<I<OuncommentLine"
  292.         "<SuncommentBox"
  293.         "<ScommentBox"
  294.         "<S<EuncommentParagraph"
  295.         "<ScommentParagraph"
  296.         "(-"
  297.         "/=markHilite"
  298.         {menu -n namedMarks -p namedMarkProc {
  299.             "/K<Oset╔"
  300.             "/K<I<Ogoto╔"
  301.             "remove╔"
  302.             "(-"
  303.             "sort"
  304.             "sortByPosition"}}
  305.         {menu -n unnamedMarks -p unnamedMarkproc {
  306.             "set╔"
  307.             "exchangePointAndMark"}}
  308. }
  309.  
  310. proc strip {arg} {
  311.     if {[regsub -all {\\([][\{\}])} $arg {\1} v]} {return $v}
  312.     return $arg
  313. }
  314.  
  315.  
  316. #===============================================================================
  317. proc helpMenu {item} {
  318.     global HOME
  319.     if {$item == "Alpha Manual"} {
  320.         edit -r "$HOME:Help:Manual"
  321.     } else {
  322.         edit -r "$HOME:Help:$item"
  323.     }
  324. }
  325. set men { "Alpha Manual" "Alpha Commands" "Tcl Commands" "(-" "Quick Start" "Readme" "Changes" "(-" }
  326. foreach f [lsort -ignore [glob "$HOME:Help:*"]] {
  327.     set f [file tail $f]
  328.     if {($f != "Manual") && ($f != "Quick Start") && ($f != "Readme") && ($f != "Changes") && ($f != "ToDo") && ($f != "Alpha Commands") && ($f != "Tcl Commands")} {
  329.         lappend men $f
  330.     }
  331. }
  332. foreach f $men {
  333.     addHelpMenu $f
  334. }
  335. unset men
  336. #===============================================================================
  337.  
  338.  
  339. proc escapeSpaces {str} {
  340.     regsub -all { } $str {\ } str2
  341.     return $str2
  342. }
  343.  
  344.  
  345. proc buildSwitches {} {
  346.     global switchApps
  347.     
  348.     menu -m -n switchTo -p switchProc {"<O<I/NNow╔" "Add╔" "Remove╔" "(-"}
  349.  
  350.     if {[info exists switchApps] && [llength $switchApps]} {
  351.         foreach app $switchApps {
  352.             lappend names [file tail $app]
  353.         }
  354.         foreach name [lsort -ignore $names] {
  355.             addMenuItem -m -l "blah" switchTo $name
  356.         }
  357.     }
  358. }
  359.  
  360.  
  361. proc switchProc {menu name} {
  362.     global switchTo switchApps
  363.  
  364.     if {$name == "Add"} {
  365.         set fname [getfile "Pick an app:"]
  366.         lappend switchApps $fname
  367.         addDef switchApps $switchApps
  368.         buildSwitches
  369.     } elseif {$name == "Remove"} {
  370.         foreach app $switchApps {
  371.             lappend apps [file tail $app]
  372.         }
  373.         set name [listpick -p "Remove which app?" $apps]
  374.         if {[set ind [lsearch $switchApps "*$name"]] >= 0} {
  375.             set switchApps [lreplace $switchApps $ind $ind]
  376.             addDef switchApps $switchApps
  377.             buildSwitches
  378.         }
  379.     } elseif {$name == "Now"} {
  380.         switchApp
  381.     } else {
  382.         if {[set ind [lsearch $switchApps "*$name"]] >= 0} {
  383.             if {[catch {switchTo $name}]} {
  384.                 launch -f [lindex $switchApps $ind]
  385.             }
  386.         }
  387.     }
  388. }
  389.         
  390.  
  391. proc winTileProc {menu item} {
  392.     win$item
  393. }
  394.  
  395.  
  396.  
  397.  
  398. menu -n $winMenu -p menuWin {
  399.         "//<Szoom"
  400.         "//<S<I<OsinglePage"
  401.         "<S/;chooseAWindow"
  402.         "/I<Biconify"
  403.         {menu -n arrange -p winTileProc {
  404.             "/Jvertically^1"
  405.             "/J<O<Ihorizontally^2"
  406.             "tiled^3"
  407.             "overlay^4"
  408.             "(-"
  409.             {menu -n other {
  410.                 {bufferOtherWindow}
  411.                 {chooseAWindow}
  412.                 {chooseWindowStatus}
  413.                 {iconify}
  414.                 {killWindowStatus}
  415.                 {nextWin}
  416.                 {nextWindow}
  417.                 {otherThing}
  418.                 {prevWindow}
  419.                 {shrinkFull}
  420.                 {shrinkHigh}
  421.                 {shrinkLeft}
  422.                 {shrinkLow}
  423.                 {shrinkRight}
  424.                 {singlePage}
  425.                 {swapWithNext}
  426.                 {threeQuarters}
  427.                 {winhorizontally}
  428.                 {winoverlay}
  429.                 {wintiled}
  430.                 {winvertically}
  431.                 {zoom}
  432.             }}}}
  433.         "(-"
  434.         "/msplitWindow"
  435.         "/otoggleScrollbar"
  436.         "(-"
  437. }
  438.  
  439. # We may be reloading, so add whatever windows we have
  440. if {[info exists winNameToNum]} {
  441.     set nms [array names winNameToNum]
  442.     foreach name $nms {
  443.         regexp {[^:]*$} $name item
  444.         set num $winNameToNum($name)
  445.         if {$num < 10}     {
  446.             addMenuItem -m $winMenu /$num$item
  447.         } else {
  448.             addMenuItem -m $winMenu $item
  449.         }
  450.     }
  451. }
  452.  
  453. insertMenu "File"
  454. insertMenu "Edit"
  455. insertMenu "Text"
  456. insertMenu "Search"
  457. insertMenu "Utils"
  458. #enableMenuItem NamedClipboards paste off
  459. insertMenu "Config"
  460. menu -n $fsetMenuName {}; 
  461. insertMenu $winMenu
  462.  
  463. # catch {insertMenu $helpMenu}
  464.  
  465. # set modeMenus(global) "File Edit Text Search Utils Config $fsetMenuName $winMenu $mailMenu"
  466. # set menuTrans($fsetMenuName) "File Sets"
  467. # set menuTrans($winMenu) "Windows"
  468. # set menuTrans($mailMenu) "Eudora"
  469.  
  470. menu -n $terrMenu {}
  471.  
  472. menu -n $toolserverMenu {}
  473.  
  474.